accounts = {
    "admin": {"pw": "123456", "role": "admin"},
    "lisi": {"pw": "123456", "role": "common"}
}


def login():
    print("请先进行登录")
    username = input("请输入用户名：")
    if username not in accounts:
        print("没有这个用户名")
        return None
    user = accounts[username]
    password = ""
    try_count = 0
    while user['pw'] != password:
        if try_count > 4:
            print("密码输入错误三次，此次登录无法进行，请重新开始登录")
            return None
        password = input("请输入密码：")
        if user['pw'] != password:
            print("密码输入错误，请重新输入")
            try_count += 1
            continue
    print("登录成功")
    return user['role']
